<?php

namespace app\api\controller;

use app\api\model\Venue;
use app\common\controller\Api;
use think\App;
use think\facade\Config;
use think\Request;

/**
 * 首页接口.
 */
class Index extends Api
{
    protected $noNeedLogin = ['test', 'venueList'];
    protected $noNeedRight = ['*'];

    /**
     * 构造方法
     * @access public
     * @param Request $request Request 对象
     */
    public function __construct(Request $request = null)
    {
        parent::__construct(App::getInstance());
    }

    public function _initialize()
    {
        parent::_initialize();
        if (!Config::get('fastadmin.usercenter')) {
            $this->error(__('User center already closed'));
        }
    }

    public function test()
    {
        $data = [
            'token' => 'e5f82af2-0a1b-4337-be17-32cf5d22b94e',
            'id' => 149
//            'venue_id' => 1,
//            'date' => '2022-10-11',
//            'all_money' => 800,
//            "time_list" => [
//                    [
//                        "site_id" => 5,
//                        "time" => "12:00-13:00",
//                        "money" => "60"
//                    ],
//                    [
//                        "site_id" => 5,
//                        "time" => "11:30-13:00",
//                        "money" => "90"
//                    ]
//              ]
        ];
        $data = json_encode($data);
        dump(base64_encode($data));
    }

    /**
     *  场馆列表
     */
    public function venueList(){
        $requestData = $this->requestData;
        $data  = Venue::venueList($requestData);
        $this->getReturnData($data);
    }



    public function getConfig(){
        $user = $this->auth->getUserinfo();

        $data  = (new \app\common\model\Config())->getConfig($user);
        $this->getReturnData($data);
    }
}
